package com.git.code.service.common.advice;


import com.git.code.service.common.exception.AdException;
import com.git.code.service.common.vo.CommonResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

/**
 * @creatdate 2019-12-09 20:21
 */

@RestControllerAdvice
public class GlobalExceptionAdvice {

    @ExceptionHandler(value = AdException.class)
    public CommonResponse<String> handlerAdException(HttpServletRequest request, AdException adExecption){
        CommonResponse<String> response = new CommonResponse<>(-1, "Bussness error");
        response.setDate(adExecption.getMessage());
        return response;
    }
}
